package gao.xiaolei.controller;

import gao.xiaolei.dto.JobkeyDto;
import gao.xiaolei.stream.StreamClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/message")
@EnableBinding(value = {StreamClient.class})
public class Controller {
    @Autowired
    private StreamClient streamClient;

    @PostMapping("/quertz")
    public void testSend(@RequestBody JobkeyDto jobkeyDto){
        streamClient.output().send(MessageBuilder.withPayload(jobkeyDto).build());
    }
}
